<template>
  <view class="content" @click="genduoChage = false">
    <view class="top heads" :style="'padding-top:' + statusBarHeight1 + 'px'">
      <image
        class="backs"
        src="https://pic.bangbangtongcheng.com/static/fanhui_bai.png"
        @click="backTo"
      />
      <view class="toptitles">
        {{ nikeName && nikeName != 'undefined' ? nikeName : '未命名用户' }}
      </view>
    </view>
    <scroll-view
      class="scroll-view"
      :scroll-top="scrollNum"
      :refresher-enabled="true"
      :refresher-triggered="status"
      @refresherrefresh="getData1"
      @refresherrestore="status = false"
      refresher-background="#F3F3F3"
      scroll-y
    >
      <view
        class="content-box"
        @touchstart="touchstart"
        id="content-box"
        :class="{ 'content-showfn': showFunBtn }"
      >
        <!-- 背景图- 定位方式 -->
        <!-- <image class="content-box-bg" :src="user_info.chatBgImg" :style="{ height: imgHeight }"></image> -->
        <view class="message" v-for="(item, index) in dataList" :key="index" :id="'id-' + index">
          <view class="message-item" :class="item.usertype == 1 ? 'right' : 'left'">
            <image
              class="img"
              @click="userfy(item)"
              :src="
                item.rendImage
                  ? item.rendImage
                  : 'https://pic.bangbangtongcheng.com/static/my/header.png'
              "
            >
            </image>
            <!-- contentType = 1 文本  v-if="item.contentType == 1"-->
            <!-- <view class="content">{{ item.content }}</view> -->
            <rich-text
              class="content"
              v-if="item.contentType == '1'"
              :nodes="item.content"
            ></rich-text>
            <!-- contentType = 2 图片 -->
            <rich-text
              class="content2"
              v-if="item.contentType == '2'"
              :nodes="item.content"
              @itemclick="goImgDetials(item.content)"
            ></rich-text>
            <!-- contentType = 3 发送房源 -->
            <template v-if="item.contentType == '3'">
              <view
                class="information"
                v-if="item.content.characteristicData == 1"
                @click="details(item.content.id)"
              >
                <image
                  mode="aspectFit"
                  :src="
                    item.content.displayDiagram
                      ? item.content.displayDiagram
                      : item.content.houseImage.split('|')[0]
                  "
                />
                <view class="li_1" style="max-width: 134px">
                  <view class="tit">{{ item.content.title }}</view>
                  <view class="jiedao"
                    >{{ item.content.region }} {{ item.content.cellName || '' }}
                    {{ item.content.floor || '' }}
                  </view>
                  <view style>{{ item.content.AREA || item.content.area }}㎡</view>
                  <view class="shijian">
                    <span
                      style="margin-right: 24rpx; color: red; font-size: 36rpx; font-weight: 600"
                      v-if="item.content.transactionType == 2"
                      >{{ item.content.price }}万</span
                    >
                    <span
                      style="margin-right: 24rpx; color: red; font-size: 36rpx; font-weight: 600"
                      v-if="item.content.transactionType == 1 && item.content.price <= 10000"
                      >{{ item.content.price }}元</span
                    >
                    <span
                      style="margin-right: 24rpx; color: red; font-size: 36rpx; font-weight: 600"
                      v-if="item.content.transactionType == 1 && item.content.price > 10000"
                      >{{ item.content.price / 10000 }}万元</span
                    >
                  </view>
                </view>
              </view>
              <!-- 车源车系 -->
              <view
                class="information"
                v-else-if="item.content.characteristicData == 2"
                @click="czdetails(item.content)"
              >
                <image mode="aspectFit" :src="item.content.vehicleCoverPicture" />
                <view class="li_1" style="max-width: 100px">
                  <view class="vehicleRecom">
                    <span v-if="item.content.vehicleType == 2"
                      >{{ item.content.vehicleBrandModel.split('|')[0] + ' ' }}
                      {{
                        item.content.vehicleBrandModel.split('|')[1]
                          ? item.content.vehicleBrandModel.split('|')[1] + '/'
                          : '/'
                      }}
                      {{
                        item.content.mileage < 10000
                          ? item.mileage + '公里/'
                          : (item.content.mileage / 10000).toFixed(1) + '万公里/'
                      }}
                      {{ item.content.licensingTimeYear }}</span
                    >
                    <span v-else
                      >{{ item.content.vehicleBrandModel.split('|')[0] + ' ' }}
                      {{
                        item.content.vehicleBrandModel.split('|')[1]
                          ? item.content.vehicleBrandModel.split('|')[1] + '/'
                          : '/'
                      }}
                      {{ item.content.model ? item.content.model + '/' : '' }}
                      {{
                        item.content.bodyStructureDoors +
                        '门' +
                        item.content.bodyStructureSeat +
                        '座' +
                        item.content.bodyStructureVehicle +
                        '车'
                      }}</span
                    >
                  </view>
                  <view
                    style="margin-right: 24rpx; color: red; font-size: 36rpx; font-weight: 600"
                    v-if="item.content.vehicleType != 3"
                  >
                    {{ item.content.price }}万
                  </view>
                  <view
                    style="margin-right: 24rpx; color: red; font-size: 36rpx; font-weight: 600"
                    v-else
                  >
                    {{ item.content.intervalPrice }}万
                  </view>
                </view>
              </view>
              <!-- 服务项目 -->
              <view
                class="information"
                v-else-if="item.content.characteristicData == 3"
                @click="fwdetails(item.content)"
              >
                <image mode="aspectFit" :src="item.content.coverPhoto" />
                <view class="li_1" style="max-width: 100px">
                  <view
                    style="font-size: 32rpx; font-weight: 500; color: #64b6a8; margin-bottom: 20rpx"
                    >{{ item.content.entryName }}</view
                  >
                  <view class="jiedao">
                    {{ item.content.entryDescription }}
                  </view>
                </view>
              </view>
              <!-- 全职招聘，兼职招聘 -->
              <view
                class="vacancy"
                v-else-if="item.content.characteristicData == 4"
                @click="zpdetails(item.content)"
              >
                <view class="vehicleRecom">
                  <span>{{ item.content.title }}</span>
                </view>
                <view class="vacancy_center">
                  <view class="vacancy_status">
                    <span>{{ item.content.region }}</span>
                    <span>{{ item.content.positionCategory }}</span>
                  </view>
                  <view class="vacancy_price" v-if="item.content.recruitmentType == 1">{{
                    item.content.salaryRange == '面议' ? '面议' : item.content.salaryRange + '元'
                  }}</view>
                  <view class="vacancy_price" v-else
                    >{{ item.content.salaryRange.split(',').join('') }}&emsp;{{
                      item.content.settlementMethod
                    }}</view
                  >
                </view>
                <view class="vacancy_biaoq" v-if="item.content.fringeBenefits">
                  <view class="vacancy_label">
                    <view class="shade"> </view>
                    <view
                      class="label"
                      v-for="(i, j) in item.content.fringeBenefits.split(',')"
                      :key="j"
                      >{{ i }}</view
                    >
                  </view>
                  <view class="gend" v-if="item.content.fringeBenefits.split(',').length > 4">
                    更多>
                  </view>
                </view>
                <view class="personalInformation">
                  <view class="personalInformation_left">
                    <view class="GR">
                      <image
                        class="personalInformation_image"
                        v-if="item.content.userInformationDto.image"
                        :src="item.content.userInformationDto.image"
                        mode=""
                      ></image>
                      <image
                        class="personalInformation_image"
                        v-else
                        src="https://pic.bangbangtongcheng.com/static/my/header.png"
                        mode=""
                      ></image>
                      <span class="name">{{
                        item.content.userInformationDto.nikeName
                          ? item.content.userInformationDto.nikeName
                          : '未命名用户'
                      }}</span>
                    </view>
                    <view
                      class="GS"
                      v-if="item.content.userInformationDto.enterpriseRecruitmentStatus"
                    >
                      <view class="personalInformation_image"></view>
                      <span class="corporation">{{ item.content.enterpriseName }}</span>
                    </view>
                  </view>
                  <view class="personalInformation_right">
                    <span class="personalInformation_Time">{{
                      $Time.getDateDiff(item.content.createDate)
                    }}</span>
                    <span class="personalInformation_distance" v-if="item.content.distance"
                      >{{ item.content.distance }}km</span
                    >
                  </view>
                </view>
              </view>
            </template>
          </view>
        </view>
      </view>
    </scroll-view>

    <!-- 底部聊天输入框 -->
    <view class="input-box2" :class="popupLayerClass" @touchmove.stop.prevent="discard">
      <view class="genduo">
        <image
          @click.stop="genduoClick()"
          src="https://pic.bangbangtongcheng.com/static/gengduo.png"
          mode=""
        ></image>
        <view class="administrations" v-if="genduoChage">
          <text class="items" @click.stop="shopSwitchClick(1)">
            {{ hyData.whetherTop == 1 ? '取消置顶' : '置顶' }}
          </text>
          <text class="items" @click.stop="shopSwitchClick(2)">
            {{ hyData.noDisturb == 0 ? '取消免打扰' : '免打扰' }}
          </text>
          <text class="items" @click.stop="shopSwitchClick(3)"> 举报 </text>
          <text class="items" @click.stop="shopSwitchClick(4)">
            {{ isLh ? '移出黑名单' : '拉黑' }}
          </text>
          <text class="items" style="border: none" @click.stop="shopSwitchClick(5)">
            电话联系
          </text>
        </view>
      </view>
      <view class="voice" @click="switchFun">
        <!-- <u-icon name="/static/news/voice.png" size="48"></u-icon> -->
        <image src="https://pic.bangbangtongcheng.com/static/gd.png" class="iconImg" />
      </view>
      <view class="textbox">
        <!-- <view class="voice-mode" :class="[isVoice?'':'hidden',recording?'recording':'']" @touchstart="voiceBegin" @touchmove.stop.prevent="voiceIng" @touchend="voiceEnd" @touchcancel="voiceCancel">{{voiceTis}}</view> -->
        <view class="text-mode" style="max-height: 200rpx; overflow-y: auto">
          <view class="box">
            <editor
              id="editor"
              class="ql-container"
              style="width: 100%"
              placeholder=" "
              :show-img-size="true"
              @ready="onEditorReady"
              @focus="onFocus"
              :read-only="readOnly"
            >
            </editor>
            <!-- <textarea auto-height="true" v-model="formData.content" @focus="textareaFocus"/> -->
          </view>
          <view class="em" @tap="chooseEmoji">
            <image src="https://pic.bangbangtongcheng.com/static/biaoqing.png" class="iconImg" />
            <!-- 发送 -->
          </view>
        </view>
      </view>
      <!-- 功能性按钮 -->
      <view class="flex u-p-l-20" @click="switchFun">
        <!-- <u-icon name="/static/gd.png" size="48" color="#ff6a00"></u-icon> -->
      </view>
      <view class="voice voice2">
        <view class="submit" @click="sendMsg">发送</view>
      </view>
    </view>
    <!-- 抽屉栏 -->
    <view class="popup-layer" :class="popupLayerClass" @touchmove.stop.prevent="discard">
      <!-- 表情 -->
      <view class="emoji-swiper" :class="{ hidden: hideEmoji }">
        <scroll-view scroll-y="true" style="height: 300rpx">
          <view class="u-p u-flex u-flex-wrap">
            <view
              class="u-m-b-32 emoji-box flex"
              v-for="(page, pid) in emojiList"
              :key="pid"
              @tap="clickEmoji(page)"
            >
              <image mode="widthFix" :src="page.url"></image>
            </view>
          </view>
        </scroll-view>
      </view>
      <!-- 更多功能 相册-拍照-红包 -->
      <view class="more-layer" :class="{ hidden: hideMore }">
        <view class="list">
          <view class="box u-flex-col" @tap="ChooseImage">
            <text class="cuIcon-pic" style="font-size: 28px"></text>
            <view class="grid-text">图片</view>
          </view>
        </view>
      </view>
    </view>
    <!-- //语音动画 -->
    <view class="voice_an" v-if="recording">
      <view class="voice_an_icon">
        <view id="one" class="wave"></view>
        <view id="two" class="wave"></view>
        <view id="three" class="wave"></view>
        <view id="four" class="wave"></view>
        <view id="five" class="wave"></view>
        <view id="six" class="wave"></view>
        <view id="seven" class="wave"></view>
      </view>
      <view class="text">{{ voiceIconText }}</view>
    </view>
    <view
      class="audit"
      style="
        width: 100%;
        height: 100%;
        position: fixed;
        background-color: rgba(19, 18, 18, 0.5);
        z-index: 100;
        top: 0;
      "
      @click.self="hideDiv"
      v-if="fabuZbc"
    >
      <view class="fabuZbc" v-if="block">
        <view class="tips"> 确定要将此人加入黑名单吗？ </view>
        <view class="btn">
          <view class="btn_qx" @click="hideDiv"> 取消 </view>
          <view class="btn_qd" @click="shield()"> 确定 </view>
        </view>
      </view>
      <view class="fabuZbc" v-if="tops">
        <view class="tips">
          确定要将当前聊天{{ hyData.whetherTop == 1 ? '取消置顶' : '置顶' }}吗？
        </view>
        <view class="btn">
          <view class="btn_qx" @click="hideDiv"> 取消 </view>
          <view class="btn_qd" @click="topClick()"> 确定 </view>
        </view>
      </view>
      <view class="fabuZbc" v-if="noDisturb">
        <view class="tips">
          确定要将当前聊天{{ hyData.noDisturb == 0 ? '取消免打扰' : '免打扰' }}吗？
        </view>
        <view class="btn">
          <view class="btn_qx" @click="hideDiv"> 取消 </view>
          <view class="btn_qd" @click="disturbClick()"> 确定 </view>
        </view>
      </view>
      <view class="fabuZbc" v-if="isClear">
        <view class="tips"> 确定要将此人从黑名单移除吗？ </view>
        <view class="btn">
          <view class="btn_qx" @click="hideDiv"> 取消 </view>
          <view class="btn_qd" @click="remove()"> 确定 </view>
        </view>
      </view>
    </view>
    <uniBall></uniBall>
  </view>
</template>

<script>
  import permision from '@/js_sdk/wa-permission/permission.js'
  //#ifdef H5
  import wxshare from '../../utils/index.js'
  //#endif
  import util from '../../utils/util'
  import { mapGetters } from 'vuex'
  var websocket = null
  export default {
    data() {
      return {
        readOnly: false,
        fromUserInfo: {},
        // 抽屉参数
        popupLayerClass: '',
        formData: {
          content: '',
          limit: 15,
          index: 1,
        },
        user_info: {
          address: '河南郑州',
          // chatBgImg: "/static/1.jpg",
          headImg: '/static/chat/huge.jpg',
          id: 1,
          phone: '13535351112',
          pictureBanner: '/static/chat/Ran.jpg',
          signature: 'who do you want to meet.',
          userName: 'DR',
          wechatNumber: 'October',
        },
        messageList: [],
        loading: true, //标识是否正在获取数据
        imgHeight: '1000px',
        mpInputMargin: false, //适配微信小程序 底部输入框高度被顶起的问题
        chatType: 'voice', // 图标类型 'voice'语音 'keyboard'键盘
        voiceTitle: '按住 说话',
        Recorder: uni.getRecorderManager(),
        Audio: uni.createInnerAudioContext(),
        recording: false, //标识是否正在录音
        isStopVoice: false, //加锁 防止点击过快引起的当录音正在准备(还没有开始录音)的时候,却调用了stop方法但并不能阻止录音的问题
        voiceInterval: null,
        voiceTime: 0, //总共录音时长
        canSend: true, //是否可以发送
        PointY: 0, //坐标位置
        voiceIconText: '正在录音...',
        showFunBtn: false, //是否展示功能型按钮
        AudioExam: null, //正在播放音频的实例
        userInfo: uni.getStorageSync('Pduser'),
        funList: [
          {
            url: 'https://pic.bangbangtongcheng.com/101.gif',
            alt: '[伤心]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/102.gif',
            alt: '[闭眼]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/103.gif',
            alt: '[发呆]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/104.gif',
            alt: '[飞吻]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/105.gif',
            alt: '[调皮]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/106.gif',
            alt: '[震惊]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/107.gif',
            alt: '[偷笑]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/108.gif',
            alt: '[白眼]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/109.gif',
            alt: '[生气]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/110.gif',
            alt: '[笑哭]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/111.gif',
            alt: '[害羞]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/112.gif',
            alt: '[笑]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/113.gif',
            alt: '[惊讶]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/114.gif',
            alt: '[难过]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/115.gif',
            alt: '[抓狂]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/116.gif',
            alt: '[晚安]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/117.gif',
            alt: '[哇哦]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/118.gif',
            alt: '[思考]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/119.gif',
            alt: '[笑]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/120.gif',
            alt: '[快乐]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/121.gif',
            alt: '[笑]',
          },
        ],
        dataList: [],
        editorCtx: '',
        img: '',
        nikeName: '',
        num: '',
        scrollNum: 0,
        childrenId: '',
        pageSize: '20',
        pageNo: '1',
        status: false,
        loading: false,
        imgList: [],
        jjrInfo: '',
        // more参数
        hideMore: true,
        //表情定义
        hideEmoji: true,
        emojiList: [
          {
            url: 'https://pic.bangbangtongcheng.com/100.gif',
            alt: '[尴尬]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/101.gif',
            alt: '[伤心]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/102.gif',
            alt: '[闭眼]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/103.gif',
            alt: '[发呆]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/104.gif',
            alt: '[飞吻]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/105.gif',
            alt: '[调皮]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/106.gif',
            alt: '[震惊]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/107.gif',
            alt: '[偷笑]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/108.gif',
            alt: '[白眼]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/109.gif',
            alt: '[生气]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/110.gif',
            alt: '[笑哭]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/111.gif',
            alt: '[害羞]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/112.gif',
            alt: '[笑]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/113.gif',
            alt: '[惊讶]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/114.gif',
            alt: '[难过]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/115.gif',
            alt: '[抓狂]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/116.gif',
            alt: '[晚安]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/117.gif',
            alt: '[哇哦]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/118.gif',
            alt: '[思考]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/119.gif',
            alt: '[笑]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/120.gif',
            alt: '[快乐]',
          },
          {
            url: 'https://pic.bangbangtongcheng.com/121.gif',
            alt: '[笑]',
          },
        ],
        articleId: '',
        genduoChage: false,
        HousData: {
          houseImage: '',
        },
        fabuZbc: false,
        block: false,
        noDisturb: false,
        tops: false,
        hyData: '',
        users: '',
        isLh: false,
        isClear: false,
        lhId: '',
      }
    },
    computed: {
      ...mapGetters(['statusBarHeight1', 'userinfo']),
    },
    async onLoad(options) {
      this.receiver = options.receiver
      this.nikeName = options.nikeName
      this.img = options.img
      await this.init()
      if (options.id || options.id != undefined) {
        this.articleId = options.id
        if (options.index == 1) {
          // type 1为车源车系 ，2为服务项目
          this.sendArticle(options.type)
        }
      }
      await this.getNum()
      await this.getreceiver()
      this.hyfriend()
      /* #ifdef H5 */
      this.jinzhi()
      /* #endif */
      // if(this.num)
    },
    onShow() {},
    methods: {
      async userfy(item) {
        let yy = await this.getjjr(item)
        if (yy.businessType == 1 && yy.shopType == 2 && yy.isShop == 1) {
          if (!yy.buildingId) {
            uni.showToast({
              title: '该商家还未发布楼盘！',
              icon: 'none',
              mask: true,
            })
            return
          }
          uni.navigateTo({
            url: '/pages_houses/houses/housesDetails?id=' + yy.buildingId,
          })
          return
        }
        if (yy.businessType == 0 && yy.enterpriseRecruitmentStatus == 1) {
          uni.navigateTo({
            url: '/pages_recruitMoney/recruitmentDetails/companyDetails?userId=' + yy.id,
          })
          return
        }
        let id = ''
        if (item.usertype != 1) {
          id = this.receiver
        } else {
          id = this.userInfo.id
        }

        uni.navigateTo({
          url: '/pages_owner/dealer/goldConsultant?userId=' + id,
        })
      },
      async getjjr(item) {
        let that = this
        let data = {}
        await this.$myRequest
          .get('/api/mobile/public/getPersonalHome', {
            otherId: item.usertype != 1 ? this.receiver : this.userInfo.id,
            ownerId: item.usertype != 1 ? this.userInfo.id : this.receiver,
          })
          .then((res) => {
            data = res.personalHomeData
          })
        return data
      },
      genduoClick() {
        this.genduoChage = !this.genduoChage
      },
      shopSwitchClick(index) {
        if (index == 1) {
          this.fabuZbc = true
          this.tops = true
        } else if (index == 2) {
          this.fabuZbc = true
          this.noDisturb = true
        } else if (index == 3) {
          uni.navigateTo({
            url: '/pages/news/reportUser?id=' + this.receiver,
          })
        } else if (index == 4) {
          if (this.isLh) {
            this.fabuZbc = true
            this.isClear = true
          } else {
            this.fabuZbc = true
            this.block = true
          }
        } else if (index == 5) {
          // #ifdef APP
          this.getPhone()
          // #endif
          // #ifndef APP
          this.onphone()
          // #endif
        }
        this.genduoChage = false
      },
      hideDiv() {
        this.block = false
        this.fabuZbc = false
        this.tops = false
        this.isClear = false
        this.noDisturb = false
      },
      // 获取好友信息
      hyfriend() {
        this.$myRequest
          .get('/mob/chatrecord/getChatFriendInformation', {
            userId: this.userInfo.id,
            friendId: this.receiver,
          })
          .then((res) => {
            this.hyData = res.chatUser
          })
      },
      // 置顶
      topClick() {
        this.$myRequest
          .post('/mob/chatrecord/setTopOrCancelTop', {
            userId: this.userInfo.id,
            friendId: this.receiver,
            whetherTop: this.hyData.whetherTop == 1 ? '0' : '1',
          })
          .then((res) => {
            this.hideDiv()
            uni.showToast({
              title: res.msg,
              icon: 'none',
              mask: true,
            })
            setTimeout(() => {
              this.hyfriend()
            }, 500)
          })
      },
      // 免打扰
      disturbClick() {
        this.$myRequest
          .post('/mob/chatrecord/setNoDisturbanceOrCancelNoDisturbance', {
            userId: this.userInfo.id,
            friendId: this.receiver,
            noDisturb: this.hyData.noDisturb == 0 ? '1' : '0',
          })
          .then((res) => {
            this.hideDiv()
            uni.showToast({
              title: res.msg,
              icon: 'none',
              mask: true,
            })
            setTimeout(() => {
              this.hyfriend()
            }, 500)
          })
      },
      // 拉黑
      shield() {
        this.$myRequest
          .post('/api/mobile/public/shielding', {
            pullBlack: this.userInfo.id,
            pulledBlack: this.jjrInfo.id,
          })
          .then((res) => {
            this.hideDiv()
            this.isLh = true
            this.lhId = res.blackoutInformation.id
            uni.showToast({
              title: '拉黑成功',
              icon: 'none',
              mask: true,
            })
          })
      },
      remove() {
        this.$myRequest
          .post('/api/mobile/public/cancel', {
            pullBlack: this.userInfo.id,
            ids: this.lhId,
          })
          .then((res) => {
            this.hideDiv()
            uni.showToast({
              title: '移除成功',
              icon: 'none',
            })
            setTimeout(() => {
              this.blockLists = []
              this.blockList()
            }, 500)
          })
      },
      // 电话
      async getPhone() {
        this.onphone()
      },
      onphone() {
        if (!this.userInfo.phone) {
          uni.showModal({
            title: '',
            content: '尚未登录，前往登录？',
            showCancel: true,
            success: (res) => {
              if (res.confirm) {
                //#ifdef H5
                uni.navigateTo({
                  url: '/pages/login/login?isNeedBack=true',
                })
                //#endif
                //#ifdef APP-PLUS
                uni.navigateTo({
                  url: '/pages/login/login?isNeedBack=true',
                })
                //#endif
                //#ifdef MP-WEIXIN
                uni.navigateTo({
                  url: '/pages/login/phoneLogin',
                })
                //#endif
              }
            },
          })
          return
        }
        uni.makePhoneCall({
          // 手机号
          phoneNumber: this.jjrInfo.phone,
          // 成功回调
          success: (res) => {
            console.log('调用成功!')
          },

          // 失败回调
          fail: (res) => {
            console.log('调用失败!')
          },
        })
      },
      // 点击图片
      goImgDetials(imgPath) {
        console.log('imgPath', imgPath)
        var curIndex = 0
        var curStr = imgPath.match(/src\=(\S*)></)[1]
        var arr = []
        var str
        var dataList = this.dataList.filter((item) => item.contentType == '2')
        var startIndex = 0
        var endIndex = 0
        dataList.map((item, index) => {
          startIndex = item.content.indexOf('src=')
          endIndex = item.content.indexOf('><')
          str = item.content.substring(startIndex + 4, endIndex)
          // return
          // str = item.content.match(/src\=(\S*)></)[1];
          arr.push(str)
          if (curStr == str) {
            curIndex = index
          }
        })
        uni.previewImage({
          current: curIndex,
          indicator: 'default',
          urls: arr,
        })
      },
      async ChooseImage() {
        this.ChooseImage1()
      },
      ChooseImage1() {
        let _this = this
        _this.imgList = []
        uni.chooseImage({
          count: 9,
          sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
          sourceType: ['camera', 'album'],
          success(res) {
            //因为有一张图片， 输出下标[0]， 直接输出地址
            const tempFiles = res.tempFiles
            let panduan = false
            tempFiles.forEach((i, j) => {
              let length = ''
              // #ifdef H5
              length = i.name.length
              let resType = i.name.substring(length - 1, length)
              // #endif
              // #ifndef H5
              length = i.path.length
              let resType = i.path.substring(length - 1, length)
              // #endif
              if (resType != 'g' && resType != 'G') {
                panduan = true
              }
            })
            if (panduan) {
              uni.showToast({
                title: '不支持当前文件格式',
                icon: 'none',
              })
              return
            }
            var imgFiles = res.tempFilePaths
            // console.log(imgFiles);
            if (imgFiles.length > 9) {
              uni.showToast({
                title: '图片最多不能超过9张',
                duration: 2000,
                icon: 'none',
              })
              return
            }
            var uper
            imgFiles.forEach((el) => {
              uni.showToast({
                title: '正在上传请稍后',
                icon: 'none',
                duration: 2000,
              })
              uper = uni.uploadFile({
                // 需要上传的地址
                url: 'https://www.bangbangtongcheng.com/conven/ht/attach/qnUpload',
                // filePath 需要上传的文件
                filePath: el,
                name: 'file',
                success(res1) {
                  // console.log(res1.data);
                  _this.sendImg(
                    `<img class="sendIamge" style="width:100%" src=` +
                      _this.$imgSrc +
                      JSON.parse(res1.data).data[0].url +
                      `></img>`
                  )
                  _this.imgList.push(JSON.parse(res1.data).data[0].url)
                  return
                  for (var i = 0; i < _this.imgList.length; i++) {
                    console.log(_this.imgList[i])
                    // _this.editorCtx.insertImage({
                    //     src: _this.$imgSrc + _this.imgList[i],
                    //     width: '100%',
                    //     extClass: "sendIamge",
                    //     success: function () {
                    //       console.log("insert image success");
                    //     },
                    //   });
                    // _this.editorCtx.setContents();
                    _this.sendImg(
                      `<img class="sendIamge" style="width:100%" src=` +
                        _this.$imgSrc +
                        _this.imgList[i] +
                        `></img>`
                    )
                  }
                },
              })
            })

            // onProgressUpdate 上传对象更新的方法
            uper.onProgressUpdate(function (res) {})
          },
          fail: (fail) => {
            uni.showModal({
              title: '提示',
              content: '操作权限已被拒绝，请手动前往设置',
              confirmText: '立即设置',
              success: (res) => {
                if (res.confirm) {
                  if (plus.os.name === 'iOS') {
                    plus.runtime.openURL('app-settings://')
                  } else {
                    var Intent = plus.android.importClass('android.content.Intent')
                    var Settings = plus.android.importClass('android.provider.Settings')
                    var Uri = plus.android.importClass('android.net.Uri')
                    var mainActivity = plus.android.runtimeMainActivity()
                    var intent = new Intent()
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                    var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
                    intent.setData(uri)
                    mainActivity.startActivity(intent)
                  }
                }
              },
            })
          },
        })
      },
      getreceiver() {
        let that = this
        this.$myRequest
          .get('/mob/user/getUserInfoByUserId', {
            id: this.receiver,
          })
          .then((res) => {
            res.userInfo.scoreAvg = res.scoreAvg
            if (res.userInfo.image) {
              let arr = res.userInfo.image.split('')
              if (arr[0] == '/') {
                res.userInfo.image = that.imgUrl + res.userInfo.image
              }
              that.img = res.userInfo.image
            }
            this.jjrInfo = res.userInfo
          })
      },
      jinzhi() {
        let _this = this
        let param = window.location.href.split('#')[0]
        uni.request({
          method: 'post',
          data: {
            url: param,
          },
          header: {
            'content-type': 'application/x-www-form-urlencoded',
          },
          url: 'https://www.bangbangtongcheng.com/conven//mob/login/getJsTicket.do',
          success(re) {
            _this.jinzhifx(re.data)
          },
        })
      },
      jinzhifx(data) {
        wxshare.config({
          debug: false, //是否打开调试
          appId: data.appId, // 公众号的唯一标识
          timestamp: data.timestamp, // 生成签名的时间戳
          nonceStr: data.nonce, // ，生成签名的随机串
          signature: data.signature, // 签名
          jsApiList: ['hideMenuItems'],
        })
        // 禁止分享
        wxshare.hideMenuItems({
          // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
          menuList: [
            'menuItem:share:appMessage',
            'menuItem:share:timeline',
            'menuItem:share:timeline',
            'menuItem:share:qq',
            'menuItem:favorite',
            'menuItem:share:QZone',
            'menuItem:openWithSafari',
          ],
        })
      },
      readChat() {
        this.$myRequest
          .post('/mob/chatrecord/readChat', {
            sender: this.receiver,
            receiver: this.userInfo.id,
          })
          .then((res) => {
            // console.log(res);
            // this.data = res.data.list;
          })
      },
      getNum() {
        this.$myRequest
          .get('/mob/chatrecord/getChatRecordList', {
            receiver: this.receiver,
            sender: this.userInfo.id,
            pageNo: 1,
            pageSize: 1,
          })
          .then((res) => {
            // console.log(res);
            this.num = res.data.count
            if (this.num > 20) {
              this.pageNo = Math.ceil(this.num / 20)
            }
            this.readChat()
            this.getData()
          })
      },
      backTo() {
        // uni.navigateBack(-1)
        console.log(213)
        this.$u.route({
          type: 'back',
          delta: 1,
        })
        // uni.switchTab({
        // 	url:"/pages/news/index"
        // })
      },
      getData() {
        this.$myRequest
          .get('/mob/chatrecord/getChatRecordList', {
            receiver: this.receiver,
            sender: this.userInfo.id,
            pageNo: this.pageNo,
            pageSize: this.pageSize,
          })
          .then((res) => {
            // console.log(res);
            let list = res.data.list
            list.forEach((el) => {
              if (el.content) {
                if (el.content.search('sendIamge') != -1) {
                  el.contentType = '2'
                } else if (el.content.search('characteristicData') != -1) {
                  el.contentType = '3'
                  el.content = JSON.parse(el.content)
                } else {
                  el.contentType = '1'
                }
              }
            })
            if (res.data.list.length) this.dataList = res.data.list
            this.setScroll()
          })
      },
      getData1() {
        let that = this
        if (this.pageNo != 1) {
          this.pageNo--
        } else {
          that.status = true
          setTimeout(function () {
            that.status = false
          }, 500)
          return
        }
        if (this.loading) {
          setTimeout(function () {
            that.status = false
          }, 500)
          return
        }

        this.loading = true
        that.status = true
        this.$myRequest
          .get('/mob/chatrecord/getChatRecordList', {
            receiver: this.receiver,
            sender: this.userInfo.id,
            pageNo: this.pageNo,
            pageSize: this.pageSize,
          })
          .then((res) => {
            console.log(res)
            let list = res.data.list.reverse()
            list.forEach((el) => {
              if (el.content) {
                if (el.content.search('sendIamge') != -1) {
                  el.contentType = '2'
                } else if (el.content.search('characteristicData') != -1) {
                  el.contentType = '3'
                  el.content = JSON.parse(el.content)
                } else {
                  el.contentType = '1'
                }
              }
              that.dataList.unshift(el)
            })
            setTimeout(function () {
              that.status = false
            }, 500)
            that.loading = false
            // this.dataList = res.data.list;
          })
      },
      test(e) {
        console.log(e)
      },
      setScroll() {
        let that = this
        // let len = this.dataList.length;
        // this.childrenId = "id-" + (len - 1);
        console.log('聊天消息到最底部')
        this.$nextTick(function () {
          setTimeout(function () {
            that.scrollNum = 999999999
          }, 100)
        })
      },
      // setScroll() {
      //   setTimeout(() => {
      //     uni.pageScrollTo({ scrollTop: 99999, duration: 0 });
      //   }, 50);
      // },
      onEditorReady() {
        console.log('aaaaaaaaaa')
        uni
          .createSelectorQuery()
          .select('#editor')
          .context((res) => {
            // console.log(res);
            this.editorCtx = res.context
          })
          .exec()
      },
      // 打开抽屉
      openDrawer() {
        this.popupLayerClass = 'showLayer'
      },
      // 隐藏抽屉
      hideDrawer() {
        console.log('bbbbbbbbb')
        this.popupLayerClass = ''
        // setTimeout(() => {
        this.hideMore = true
        this.hideEmoji = true
        // }, 150);
      },
      discard() {
        return
      },
      onHide() {
        // uni.closeSocket();
      },
      init() {
        var _this = this
        var username = this.userInfo.id
        websocket = uni.connectSocket({
          url: `${this.$commonChat}/webSocket/${username}`,
          // url: "wss://" + "www.bangbangtongcheng.com/conven/webSocket/" + username,
          success(res) {
            console.log('连接成功 connectSocket=', res)
          },
          fail(err) {
            console.log('连接失败 connectSocket=', err)
          },
        })
        uni.onSocketOpen(function (res) {
          console.log('WebSocket连接已打开！')
          // 维持心跳
          heartCheck.start()
        })
        uni.onSocketError(function (res) {
          console.log(res)
          console.log('WebSocket连接打开失败，请检查！')
        })
        //接收到消息的回调方法
        uni.onSocketMessage(function (event) {
          console.log('收到服务器内容：' + event.data)
          if (event.data == 'heartbeat') {
            // 维持心跳
            heartCheck.start()
            if (event.data != 'heartbeat') {
              document.getElementById('text').value = event.data
              console.log(event.data)
            }
            return false
          }
          let contentType = '1'
          if (event.data.search('sendIamge') != -1) {
            contentType = '2'
          } else if (event.data.search('characteristicData') != -1) {
            contentType = '3'
            event.data = JSON.parse(event.data)
          } else {
            console.log(event.data, '需要的数据')
            contentType = '1'
          }
          console.log('发送人信息：' + _this.nikeName + _this.img)
          _this.dataList.push({
            usertype: 2,
            time: util.formatDate.format(new Date(), 'yyyy-MM-dd hh:mm:ss'),
            name: _this.nikeName,
            content: event.data,
            rendImage: _this.img,
            contentType: contentType,
          })
          _this.scrollNum = 0
          _this.setScroll()
        })
        var heartCheck = {
          timeout: 1000 * 60 * 1,
          timeoutObj: null,
          serverTimeoutObj: null,
          start: function () {
            console.log(getNowTime() + ' Socket 心跳检测')
            var self = this
            this.timeoutObj && clearTimeout(this.timeoutObj)
            this.serverTimeoutObj && clearTimeout(this.serverTimeoutObj)
            this.timeoutObj = setTimeout(function () {
              //这里发送一个心跳，后端收到后，返回一个心跳消息，
              //onmessage拿到返回的心跳就说明连接正常
              console.log(getNowTime() + ' Socket 连接重试')
              websocket.send('heartbeat')
              self.serverTimeoutObj = setTimeout(function () {
                console.log(this)
                close()
              }, self.timeout)
            }, this.timeout)
          },
        }

        function p(s) {
          return s < 10 ? '0' + s : s
        }

        function getNowTime() {
          var myDate = new Date()
          //获取当前年
          var year = myDate.getFullYear()
          //获取当前月
          var month = myDate.getMonth() + 1
          //获取当前日
          var date = myDate.getDate()
          var h = myDate.getHours() //获取当前小时数(0-23)
          var m = myDate.getMinutes() //获取当前分钟数(0-59)
          var s = myDate.getSeconds()
          return year + '-' + p(month) + '-' + p(date) + ' ' + p(h) + ':' + p(m) + ':' + p(s)
        }
      },
      rtrim(str) {
        //删除右边的空格
        return str.replace(/(\s*$)/g, '')
      },
      sendMsg: function () {
        var _this = this
        let content = ''
        let text = ''
        this.editorCtx.getContents({
          success: (res) => {
            content = res.html
            var ishavaimg = content.search('img') != -1
            text = _this.rtrim(res.text)
            if (text == '' && !ishavaimg) {
              uni.showToast({
                title: '请输入消息',
                icon: 'none',
                mask: true,
              })
              return
            }
            console.log(websocket)
            // return;
            this.dataList.push({
              usertype: 1,
              time: util.formatDate.format(new Date(), 'yyyy-MM-dd hh:mm:ss'),
              name: this.userInfo.nikeName,
              content: content,
              rendImage: this.userInfo.image,
              contentType: 1,
            })
            // var username = localStorage.getItem("sysId");
            let sendText = {
              sender: this.userInfo.id,
              receiver: this.receiver,
              content: content,
            }
            // #ifdef H5
            websocket._webSocket.send(JSON.stringify(sendText))
            // #endif
            // #ifdef MP
            uni.sendSocketMessage({
              data: JSON.stringify(sendText),
            })
            // #endif
            // #ifdef APP-PLUS
            // websocket.send(JSON.stringify(sendText));
            uni.sendSocketMessage({
              data: JSON.stringify(sendText),
            })
            // #endif
            // uni.sendSocketMessage(JSON.stringify(sendText));
            _this.editorCtx.setContents({
              html: '',
            })
            _this.scrollNum = 0
            _this.setScroll()
          },
        })

        //this.focusTxtContent();//聚焦输入框
      },
      sendImg: function (imgText) {
        var _this = this
        let content = imgText
        if (content == '') {
          uni.showToast({
            title: '请选择图片',
            icon: 'none',
            mask: true,
          })
          return
        }
        this.dataList.push({
          usertype: 1,
          time: util.formatDate.format(new Date(), 'yyyy-MM-dd hh:mm:ss'),
          name: this.userInfo.nikeName,
          content: content,
          rendImage: this.userInfo.image,
          contentType: 2,
        })
        // var username = localStorage.getItem("sysId");
        let sendText = {
          sender: this.userInfo.id,
          receiver: this.receiver,
          content: content,
        }
        // #ifdef H5
        websocket._webSocket.send(JSON.stringify(sendText))
        // #endif
        // #ifdef MP
        uni.sendSocketMessage({
          data: JSON.stringify(sendText),
        })
        // #endif
        // #ifdef APP-PLUS
        // websocket.send(JSON.stringify(sendText));
        uni.sendSocketMessage({
          data: JSON.stringify(sendText),
        })
        // #endif
        // uni.sendSocketMessage(JSON.stringify(sendText));
        _this.editorCtx.setContents({
          html: '',
        })
        _this.scrollNum = 0
        _this.setScroll()
        //this.focusTxtContent();//聚焦输入框
      },
      // 发送商品数据
      async sendArticle(type) {
        var _this = this
        let content = ''
        if (type == 1) {
          await _this.getVehicleData(this.articleId)
          content = this.HousData
          content.characteristicData = 2
        } else if (type == 2) {
          await _this.getOwnerServiceData(this.articleId)
          content = this.HousData
          content.characteristicData = 3
        } else if (type == 3) {
          await _this.getRecruitData(this.articleId)
          content = this.HousData
          content.characteristicData = 4
        } else {
          await _this.getArticleData(this.articleId)
          content = this.HousData
          content.characteristicData = 1
        }
        _this.dataList.push({
          usertype: 1,
          time: util.formatDate.format(new Date(), 'yyyy-MM-dd hh:mm:ss'),
          name: this.userInfo.nikeName,
          content: content,
          rendImage: this.userInfo.image,
          contentType: 3,
        })
        // var username = localStorage.getItem("sysId");
        let sendText = {
          sender: this.userInfo.id,
          receiver: this.receiver,
          content: JSON.stringify(content),
        }
        // #ifdef H5
        websocket._webSocket.send(JSON.stringify(sendText))
        // #endif
        // #ifdef MP
        uni.sendSocketMessage({
          data: JSON.stringify(sendText),
        })
        // #endif
        // #ifdef APP-PLUS
        // websocket.send(JSON.stringify(sendText));
        uni.sendSocketMessage({
          data: JSON.stringify(sendText),
        })
        // #endif
        // uni.sendSocketMessage(JSON.stringify(sendText));
        _this.editorCtx.setContents({
          html: '',
        })
        _this.scrollNum = 0
        _this.setScroll()
        //this.focusTxtContent();//聚焦输入框
      },
      // 通过id取商品数据
      async getArticleData(id) {
        let that = this
        await this.$myRequest
          .get('/mob/home/getHouseInfoDetail', {
            id: id,
          })
          .then((res) => {
            if (res.tHouseInfo.floor) {
              if (res.tHouseInfo.floor.indexOf('|') != -1) {
                res.tHouseInfo.floor = res.tHouseInfo.floor.split('|')[1] + '层'
              }
            }
            this.HousData = res.tHouseInfo
          })
      },
      // 通过id取车源，车系数据
      async getVehicleData(id) {
        let that = this
        await this.$myRequest
          .get('/api/mobile/vehicleOwner/queryVehicleInformationById', {
            vehicleId: id,
            userId: this.userInfo.id,
          })
          .then((res) => {
            this.HousData = res.vehicleInformation
          })
      },
      // 通过id取服务项目数据
      async getOwnerServiceData(id) {
        let that = this
        await this.$myRequest
          .get('/api/mobile/vehicleOwner/getOwnerServiceById', {
            id: id,
            userId: this.userInfo.id,
          })
          .then((res) => {
            this.HousData = res.serviceItems
          })
      },
      // 通过id取招聘数据
      async getRecruitData(id) {
        let that = this
        await this.$myRequest
          .get('/api/mobile/personnelOwner/getRecruitmentById', {
            id: id,
            userId: this.userInfo.id,
          })
          .then((res) => {
            this.HousData = res.recommendedPosition
          })
      },
      zpdetails(item) {
        if (item.recruitmentType == '1') {
          uni.navigateTo({
            url: '/pages_recruitMoney/recruitmentDetails/fullTime?id=' + item.id,
          })
        } else {
          uni.navigateTo({
            url: '/pages_recruitMoney/recruitmentDetails/concurrently?id=' + item.id,
          })
        }
      },
      czdetails(item) {
        if (item.vehicleType == 3) {
          uni.navigateTo({
            url: '/pages_owner/index/carSeriesDetails?id=' + item.id,
          })
        } else {
          uni.navigateTo({
            url: '/pages_owner/index/vehicleDetails?id=' + item.id,
          })
        }
      },
      fwdetails(item) {
        uni.navigateTo({
          url: '/pages_owner/ownerService/servicesAvailableDetails?id=' + item.id,
        })
      },
      details(id) {
        uni.navigateTo({
          url: '/pages_houses/housing/used/houseDetails?id=' + id,
        })
      },
      //获取焦点，如果不是选表情ing,则关闭抽屉
      textareaFocus() {
        if (this.popupLayerClass == 'showLayer' && this.hideMore == false) {
          this.hideDrawer()
        }
      },
      //拼接消息 处理滚动
      async joinData() {
        if (!this.loading) {
          //如果没有获取数据 即loading为false时，return 避免用户重复上拉触发加载
          return
        }
        this.loading = false
        const data = await this.getMessageData()
        //获取节点信息
        const { index } = this.formData
        const sel = `#msg-${
          index > 1 ? this.messageList[0].hasBeenSentId : data[data.length - 1].hasBeenSentId
        }`
        this.messageList = [...data, ...this.messageList]
        //填充数据后，视图会自动滚动到最上面一层然后瞬间再跳回bindScroll的指定位置 ---体验不是很好，后期优化 ·
        this.$nextTick(() => {
          this.bindScroll(sel)
          //如果还有数据
          if (this.formData.limit >= data.length) {
            this.formData.index++
            setTimeout(() => {
              this.loading = true
            }, 200)
          }
        })
      },
      //处理滚动
      bindScroll(sel, duration = 0) {
        const query = uni.createSelectorQuery().in(this)
        query
          .select(sel)
          .boundingClientRect((data) => {
            uni.pageScrollTo({
              scrollTop: data && data.top - 40,
              duration,
            })
          })
          .exec()
      },
      //获取消息
      getMessageData() {
        let getData = () => {
          let arr = []
          let startIndex = (this.formData.index - 1) * this.formData.limit
          let endIndex = startIndex + this.formData.limit
          for (let i = startIndex; i < endIndex; i++) {
            const isItMe = Math.random() > 0.5 ? true : false
            arr.unshift({
              hasBeenSentId: i, //已发送过去消息的id
              content: `很高兴认识你，这是第${i + 1}条消息。`,
              fromUserHeadImg: isItMe ? this._user_info.headImg : this.fromUserInfo.fromUserHeadImg, //用户头像
              fromUserId: isItMe ? this._user_info.id : this.fromUserInfo.fromUserId,
              isItMe, //true此条信息是我发送的 false别人发送的
              createTime: Date.now(),
              contentType: 1, // 1文字文本 2语音
            })
          }
          return arr
        }
        return new Promise((resolve, reject) => {
          const data = getData()
          setTimeout(() => {
            resolve(data)
          }, 500)
        })
      },
      //切换语音或者键盘方式
      switchChatType(type) {
        this.chatType = type
        this.showFunBtn = false
      },
      //切换功能性按钮
      switchFun() {
        /* this.chatType = 'keyboard'
				          this.showFunBtn = !this.showFunBtn;
				          this.hideEmoji = false;
				          uni.hideKeyboard()*/
        this.hideEmoji = true
        this.scrollNum = 0
        this.setScroll()
        if (this.hideMore) {
          this.hideMore = false
          this.openDrawer()
        } else {
          this.hideDrawer()
        }
      },
      // 点击选择表情
      chooseEmoji() {
        this.hideMore = true
        if (this.hideEmoji) {
          this.hideEmoji = false
          this.openDrawer()
        } else {
          this.hideDrawer()
        }
      },
      //发送消息
      // sendMsg(data) {
      //   const params = {
      //     hasBeenSentId: Date.now(), //已发送过去消息的id
      //     content: this.formData.content,
      //     fromUserHeadImg: this._user_info.headImg, //用户头像
      //     fromUserId: this._user_info.id,
      //     isItMe: true, //true此条信息是我发送的  false别人发送的
      //     createTime: Date.now(),
      //     contentType: 1,
      //   };

      //   if (data) {
      //     if (data.contentType == 2) {
      //       //说明是发送语音
      //       params.content = data.content;
      //       params.contentType = data.contentType;
      //       params.contentDuration = data.contentDuration;
      //       params.anmitionPlay = false;
      //     } else if (data.contentType == 3) {
      //       //发送图片
      //       params.content = data.content;
      //       params.contentType = data.contentType;
      //     }
      //   } else if (!this.$u.trim(this.formData.content)) {
      //     //验证输入框书否为空字符传
      //     return;
      //   }

      //   this.messageList.push(params);

      //   this.$nextTick(() => {
      //     this.formData.content = "";
      //     // #ifdef MP-WEIXIN
      //     if (params.contentType == 1) {
      //       uni.pageScrollTo({
      //         scrollTop: 99999,
      //         duration: 0, //小程序如果有滚动效果 input的焦点也会随着页面滚动...
      //       });
      //     } else {
      //       setTimeout(() => {
      //         uni.pageScrollTo({
      //           scrollTop: 99999,
      //           duration: 0, //小程序如果有滚动效果 input的焦点也会随着页面滚动...
      //         });
      //       }, 150);
      //     }
      //     // #endif

      //     // #ifndef MP-WEIXIN
      //     uni.pageScrollTo({
      //       scrollTop: 99999,
      //       duration: 100,
      //     });
      //     // #endif

      //     if (this.showFunBtn) {
      //       this.showFunBtn = false;
      //     }

      //     // #ifdef MP-WEIXIN
      //     if (params.contentType == 1) {
      //       this.mpInputMargin = true;
      //     }
      //     // #endif
      //     //h5浏览器并没有很好的办法控制键盘一直处于唤起状态 而且会有样式性的问题
      //     // #ifdef H5
      //     uni.hideKeyboard();
      //     // #endif
      //   });
      // },
      //用户触摸屏幕的时候隐藏键盘、更多功能、表情
      touchstart() {
        uni.hideKeyboard()
        this.hideEmoji = false
        this.showFunBtn = false
        this.hideDrawer() // 关闭抽屉
      },
      // userid 用户id
      linkToBusinessCard(userId) {
        this.$u.route({
          url: 'pages/businessCard/businessCard',
          params: {
            userId,
          },
        })
      },
      //准备开始录音
      startVoice(e) {
        console.log('准备开始录音')
        if (!this.Audio.paused) {
          //如果音频正在播放 先暂停。
          this.stopAudio(this.AudioExam)
        }
        this.recording = true
        this.isStopVoice = false
        this.canSend = true
        this.voiceIconText = '正在录音...'
        this.PointY = e.touches[0].clientY
        this.Recorder.start({
          format: 'mp3',
        })
      },
      //录音已经开始
      beginVoice() {
        console.log('录音已经开始')
        if (this.isStopVoice) {
          this.Recorder.stop()
          return
        }
        this.voiceTitle = '松开 结束'
        this.voiceInterval = setInterval(() => {
          this.voiceTime++
        }, 1000)
      },
      //move 正在录音中
      moveVoice(e) {
        console.log('正在录音中')
        const PointY = e.touches[0].clientY
        const slideY = this.PointY - PointY
        if (slideY > uni.upx2px(120)) {
          this.canSend = false
          this.voiceIconText = '松开手指 取消发送 '
        } else if (slideY > uni.upx2px(60)) {
          this.canSend = true
          this.voiceIconText = '手指上滑 取消发送 '
        } else {
          this.voiceIconText = '正在录音... '
        }
      },
      //结束录音
      endVoice() {
        console.log('结束录音')
        this.isStopVoice = true //加锁 确保已经结束录音并不会录制
        this.Recorder.stop()
        this.recording = false
        this.voiceTitle = '按住 说话'
      },
      //录音被打断
      cancelVoice(e) {
        console.log('录音被打断')
        this.voiceTime = 0
        this.voiceTitle = '按住 说话'
        this.canSend = false
        this.recording = false
        this.Recorder.stop()
      },
      //处理录音文件
      handleRecorder({ tempFilePath, duration }) {
        let contentDuration
        // #ifdef MP-WEIXIN
        this.voiceTime = 0
        if (duration < 600) {
          this.voiceIconText = '说话时间过短'
          setTimeout(() => {
            this.recording = false
          }, 200)
          return
        }
        contentDuration = duration / 1000
        // #endif

        // #ifdef APP-PLUS
        contentDuration = this.voiceTime + 1
        this.voiceTime = 0
        if (contentDuration <= 0) {
          this.voiceIconText = '说话时间过短'
          setTimeout(() => {
            this.recording = false
          }, 200)
          return
        }
        // #endif

        this.recording = false
        const params = {
          contentType: 2,
          content: tempFilePath,
          contentDuration: Math.ceil(contentDuration),
        }
        this.canSend && this.sendMsg(params)
      },
      //控制播放还是暂停音频文件
      handleAudio(item) {
        this.AudioExam = item
        this.Audio.paused ? this.playAudio(item) : this.stopAudio(item)
      },
      //播放音频
      playAudio(item) {
        this.Audio.src = item.content
        this.Audio.hasBeenSentId = item.hasBeenSentId
        this.Audio.play()
        item.anmitionPlay = true
      },
      //停止音频
      stopAudio(item) {
        item.anmitionPlay = false
        this.Audio.src = ''
        this.Audio.stop()
      },
      //关闭动画
      closeAnmition() {
        const hasBeenSentId = this.Audio.hasBeenSentId
        const item = this.messageList.find((it) => it.hasBeenSentId == hasBeenSentId)
        item.anmitionPlay = false
      },
      onFocus() {
        // if(!this.hideEmoji){
        // 	setTimeout(()=>{
        // 		uni.hideKeyboard()
        // 	})
        // }
      },
      //添加表情
      clickEmoji(page) {
        // '/static/img/emoji/'+page.url
        // this.formData.content += page.alt;
        this.readOnly = true
        setTimeout(() => {
          this.editorCtx.insertImage({
            src: page.url,
            alt: page.alt,
            width: 20,
            height: 20,
            extClass: 'emojiIamge',
            success: () => {
              this.readOnly = false
              this.editorCtx.blur()
              uni.hideKeyboard()
              console.log('insert image success')
            },
          })
        }, 64)
      },
      //获取焦点，如果不是选表情ing,则关闭抽屉
      /*textareaFocus(){
			            this.hideEmoji = false;
			            this.showFunBtn = false;
			        },*/
      //点击宫格时触发
      clickGrid(index) {
        if (index == 0) {
          this.chooseImage(['album'])
        } else if (index == 1) {
          this.chooseImage(['camera'])
        }
      },
      //发送图片
      chooseImage(sourceType) {
        console.log(sourceType)
        uni.chooseImage({
          // sourceType,
          sizeType: ['compressed'],
          sourceType: ['camera', 'album'],
          success: (res) => {
            this.showFunBtn = false
            for (let i = 0; i < res.tempFilePaths.length; i++) {
              const params = {
                contentType: 3,
                content: res.tempFilePaths[i],
              }
              this.sendMsg(params)
            }
          },
          fail: (fail) => {
            uni.showModal({
              title: '提示',
              content: '操作权限已被拒绝，请手动前往设置',
              confirmText: '立即设置',
              success: (res) => {
                if (res.confirm) {
                  if (plus.os.name === 'iOS') {
                    plus.runtime.openURL('app-settings://')
                  } else {
                    var Intent = plus.android.importClass('android.content.Intent')
                    var Settings = plus.android.importClass('android.provider.Settings')
                    var Uri = plus.android.importClass('android.net.Uri')
                    var mainActivity = plus.android.runtimeMainActivity()
                    var intent = new Intent()
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                    var uri = Uri.fromParts('package', mainActivity.getPackageName(), null)
                    intent.setData(uri)
                    mainActivity.startActivity(intent)
                  }
                }
              },
            })
          },
        })
      },
      //查看大图
      viewImg(imgList) {
        uni.previewImage({
          urls: imgList,
          // #ifndef MP-WEIXIN
          indicator: 'number',
          // #endif
        })
      },
    },
    onPageScroll(e) {},
    onNavigationBarButtonTap() {
      //返回按钮
      this.$u.route({
        type: 'switchTab',
        url: 'pages/news/news',
      })
    },
    // 返回按钮事件
    // onBackPress(e) {
    // 	//以下内容对h5不生效
    // 	//--所以如果用浏览器自带的返回按钮进行返回的时候页面不会重定向 正在寻找合适的解决方案
    // 	this.$u.route({
    // 		type: "switchTab",
    // 		url: "pages/news/news",
    // 	});
    // 	return true;
    // },
  }
</script>

<style lang="scss" scoped>
  @import './chat2.scss';

  // /deep/ .ql-editor{
  // 	display: flex;
  // 	align-items: center;
  // }
  ::v-deep .ql-editor {
    line-height: 52rpx;
  }

  .heads {
    padding: 0 5%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90%;
    position: relative;
    /* #ifdef MP-WEIXIN */
    width: 70%;
    padding-right: 25%;

    /* #endif */
    .backs {
      width: 32rpx;
      height: 32rpx;
      position: absolute;
      left: 5%;
      bottom: 30rpx;
    }

    .toptitles {
      font-size: 18px;
      color: #fff;
      width: 300rpx;
      text-align: center;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .jubao {
      display: flex;
      align-items: center;

      image {
        width: 54rpx;
        height: 60rpx;
      }
    }
  }

  .genduo {
    image {
      width: 54rpx;
      height: 60rpx;
      margin-top: 20rpx;
    }

    position: relative;

    .administrations {
      width: 210rpx;
      height: 390rpx;
      background-color: #fff;
      position: absolute;
      left: 0rpx;
      bottom: 140rpx;
      box-shadow: 0px 0px 20px 1px #d0d0d0;
      z-index: 100;
      padding: 0 32rpx;
      display: flex;
      flex-direction: column;

      .items {
        height: 94rpx;
        color: #5a5e66;
        font-size: 28rpx;
        border-bottom: 1px solid #e0e0e0;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      &::before {
        content: '';
        display: inline-block;
        border-left: 24rpx solid transparent;
        border-right: 20rpx solid transparent;
        border-bottom: 24rpx solid #fff;
        position: absolute;
        right: 136rpx;
        bottom: -24rpx;
        transform: rotate(180deg);
      }
    }
  }

  .fabuZbc {
    position: fixed;
    top: 30%;
    left: 50%;
    width: 600rpx;
    height: 300rpx;
    transform: translateX(-50%);
    background-color: #f3efef;
    border-radius: 10rpx;

    .tips {
      margin-top: 80rpx;
      text-align: center;
      font-size: 34rpx;
      font-weight: 400;
      color: #000000;
    }

    .btn {
      display: flex;
      justify-content: space-between;
      margin: 0 110rpx;
      margin-top: 60rpx;

      .btn_qx {
        width: 160rpx;
        height: 60rpx;
        border-radius: 37rpx;
        border: 1px solid #64b6a8;
        font-size: 30rpx;
        font-weight: 400;
        color: #64b6a8;
        text-align: center;
        line-height: 60rpx;
      }

      .btn_qd {
        width: 160rpx;
        height: 60rpx;
        background-color: #64b6a8;
        border-radius: 37rpx;
        font-size: 30rpx;
        font-weight: 400;
        color: #ffffff;
        text-align: center;
        line-height: 60rpx;
      }
    }
  }

  .content2 {
    background-color: #fff;
    margin-left: 28rpx;
    margin-right: 28rpx;
    word-break: break-all;
    line-height: 36rpx;
    position: relative;

    max-width: 500rpx;
    border-radius: 10rpx;
    font-size: 28rpx;
  }

  .vacancy {
    width: 500rpx;
    background-color: #fff;
    border-radius: 20rpx;
    min-height: 200rpx;
    margin-right: 28rpx;
    padding: 20rpx;

    .vehicleRecom {
      font-size: 28rpx;
      font-weight: 550;
      color: #333333;
      line-height: 44rpx;
      word-break: break-all;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2; //想要的行数
      -webkit-box-orient: vertical;
    }

    .vacancy_center {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 16rpx;

      .vacancy_status {
        span {
          font-size: 24rpx;
          font-weight: 400;
          color: #333333;
        }

        span:nth-child(1) {
          margin-right: 16rpx;
        }
      }

      .vacancy_price {
        font-size: 26rpx;
        font-weight: 550;
        color: #e00000;
      }
    }

    .vacancy_biaoq {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 16rpx;

      .vacancy_label {
        flex: 1;
        height: 48rpx;
        position: relative;
        overflow: hidden;
        white-space: nowrap;

        .shade {
          position: absolute;
          right: 0;
          top: 0;
          width: 100rpx;
          height: 48rpx;
          background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
        }

        .label {
          display: inline-block;
          padding: 10rpx;
          background-color: #f0f0f0;
          margin-right: 10rpx;
          font-size: 24rpx;
          font-weight: 400;
          color: #333333;
          border-radius: 4rpx;
        }

        .label:nth-last-child(1) {
          margin-right: 0rpx;
        }
      }

      .gend {
        text-align: right;
        width: 80rpx;
        height: 100%;
        font-size: 24rpx;
        color: #888888;
      }
    }

    .personalInformation {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 28rpx;

      .personalInformation_left {
        display: flex;
        flex-direction: column;

        .personalInformation_image {
          width: 42rpx;
          height: 42rpx;
          border-radius: 42rpx;
          margin-right: 12rpx;
        }

        .GR {
          display: flex;
          align-items: center;

          .name {
            flex: 1;
            font-size: 24rpx;
            font-weight: 400;
            color: #333333;
          }
        }

        .GS {
          display: flex;
          align-items: center;

          .corporation {
            flex: 1;
            white-space: break-spaces;
            font-size: 24rpx;
            font-weight: 400;
            color: #333333;
          }
        }
      }

      .personalInformation_right {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;

        .personalInformation_Time {
          white-space: nowrap;
          font-size: 24rpx;
          font-weight: 400;
          color: #888888;
          margin-bottom: 6rpx;
          text-align: right;
        }

        .personalInformation_distance {
          font-size: 24rpx;
          font-weight: 400;
          color: #888888;
          text-align: right;
        }
      }
    }
  }

  .information {
    width: 500rpx;
    background-color: #fff;
    display: flex;
    align-items: center;
    border-radius: 20rpx;
    min-height: 200rpx;
    margin-left: 28rpx;
    margin-right: 28rpx;

    image {
      background-color: #f8f8f8;
      width: 240rpx;
      height: 160rpx;
      border-radius: 20rpx;
      margin-left: 20rpx;
    }

    .li_1 {
      position: relative;
      display: inline-block;
      vertical-align: top;
      margin-left: 24rpx;
      min-height: 160rpx;

      .vehicleRecom {
        font-size: 32rpx;
        font-weight: 600;
        color: #333333;
        line-height: 44rpx;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2; //想要的行数
        -webkit-box-orient: vertical;
        margin-bottom: 10rpx;
      }

      .serviceContent {
        font-size: 24rpx;
        font-weight: 400;
        color: #333333;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
      }

      .tit {
        width: 150rpx;
        font-size: 26rpx;
        font-weight: 600;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1; //想要的行数
        -webkit-box-orient: vertical;
        margin-bottom: 10rpx;
      }

      .jiedao {
        width: 200rpx;
        font-size: 24rpx;
        margin-bottom: 14rpx;
        color: #666666;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1; //想要的行数
        -webkit-box-orient: vertical;
      }

      .shijian {
        bottom: 4rpx;
        font-size: 26rpx;
        white-space: nowrap;
        display: flex;
        align-items: center;
        margin-bottom: 10rpx;

        .ycyc {
          display: inline-block;
          width: 70rpx;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          line-height: 12.5px;
        }
      }
    }
  }
</style>
